package com.punch.punchtable.vo;

import org.springframework.data.domain.Page;

import java.util.List;

public class PageResponseVO {

    private Integer code;

    private String msg;

    private Long count;

    private List<Object> data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public List<Object> getData() {
        return data;
    }

    public void setData(List<Object> data) {
        this.data = data;
    }

    public static PageResponseVO response(Page page){
        PageResponseVO vo = new PageResponseVO();
        vo.setCode(0);
        vo.setCount(page.getTotalElements());
        vo.setData(page.getContent());
        vo.setMsg("Success");
        return vo;
    }
    public static PageResponseVO response(List items,Long count){
        PageResponseVO vo = new PageResponseVO();
        vo.setCode(0);
        vo.setCount(count);
        vo.setData(items);
        vo.setMsg("Success");
        return vo;
    }
}
